document.addEventListener('DOMContentLoaded', () => {
  var likes= document.getElementById('like')
  var likesbtn = document.getElementById('likes-btn')
  var likesofNum=document.getElementById('ofNum')
  likesbtn.addEventListener('click', () => {
    fetch('/images/likes/' + likesbtn.dataset.imageid, {method: 'POST'})
      .then(response => response.json())
      .then(data => {
        likes.textContent = data.likes
        likes.innerHTML="<i class='fa fa-heart'></i>"+' '+likes.textContent
        oldclass=likesbtn.getAttribute("class")
        //newclass=oldclass.re
        //likesbtn.setAttribute("class","btn ")
        //likesbtn.textContent="已赞"
        likesofNum.dataset.likes = + likesofNum.dataset.likes+1
        likesofNum.textContent = likesofNum.dataset.likes
        
      })
  })
})